package com.football.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseWrapper extends SQLiteOpenHelper {

	public static final String CHANNEL_TABLES = "channel";
	public static final String CHANNEL_ID = "id";
	public static final String CHANNEL_NAME = "name";
	public static final String CHANNEL_URL = "url";
	public static final String CHANNEL_DESCRIPTION = "description";

	private static final String DATABASE_NAME = "football.db";
	private static final int DATABASE_VERSION = 1;

	private static final String CHANNEL_CREATE = "create table "
			+ CHANNEL_TABLES + "(" + CHANNEL_ID
			+ " integer primary key autoincrement, " + CHANNEL_NAME
			+ " text not null, " + CHANNEL_URL + " text not null,"
			+ CHANNEL_DESCRIPTION + " text);";

	public DataBaseWrapper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CHANNEL_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// you should do some logging in here
		// ..
		db.execSQL("DROP TABLE IF EXISTS " + CHANNEL_TABLES);
		onCreate(db);
	}

}